<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../../commons/taglibs.jsp"%>
<%@ include file="../../commons/list.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta charset="utf-8">
  <title>车型数据维护</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <!-- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> -->
 <style>
.layui-table-cell .layui-form-checkbox[lay-skin="primary"]{
     top: 50%;
     transform: translateY(-50%);
}

.widget-box {
    padding: 0;
    -webkit-box-shadow: none;
    box-shadow: none;
    margin: 3px 0;
    border-bottom: 1px solid #CCC;
}

.widget-header>:first-child {
    line-height: 36px;
    padding: 0;
    margin: 0;
    display: inline;
}

.widget-header {
    box-sizing: content-box;
    position: relative;
    min-height: 38px;
    background: #f2f2f2;
    background-repeat: repeat-x;
    color: #669fc7;
    border: 1px solid #CCC;
    border-bottom: 1px solid #DDD;
    padding-left: 12px;
}

.widget-body {
    /* border: 1px solid #CCC; */
    border-top: 0;
    background-color: #FFF;
    height : 90%; 
    /* overflow: auto; */
    position: absolute;
    width: 20%;
}

.widget-main.padding-8 {
    padding: 8px;
}

h5.smaller {
    font-size: 16px;
}

.lighter {
    font-weight: lighter;
}

.labelInput{
	border: 0px;
	height: 50px;
    width: 70%;
    margin-top: -10px;
}
</style>
	<link rel="stylesheet" href="<%=basePath%>common/plugins/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="<%=basePath%>common/plugins/zTree/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>common/plugins/zTree/js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="<%=basePath%>common/plugins/zTree/js/jquery.ztree.excheck.js"></script>
	
</head>

<body>
<div id="zong" style="padding: 10px">
	<input id='carmodelid' value="${carmodelid }" type="hidden">
	<div  id ="leftTree" style="width: 20%;float:left;height:100%;line-height: 50px;">
 		<div class="widget-box" style="width: 100%;">
  			<div class="widget-header">
				<h5 class="lighter smaller">信息展示</h5>
			</div>
			<div class="widget-body">
				<div style="height:100%; border:1px #aaa solid;text-align: center; width: 97.3%;">
					<ul id="treeDemo" class="ztree"></ul>
				</div>
			</div>
		</div>
	</div>
	
	<div id ="rightForm" style="width: 80%;float:right;margin-top:10px">
		<iframe id='showIframe' frameborder="0" height="600px" width="100%"/></iframe>
	</div>

 </div> 
 
<script>
//Demo
layui.use('form', function(){
  var form = layui.form;
  //监听提交
  form.on('submit(formDemo)', function(data){
	  var zTreeOjb = $.fn.zTree.getZTreeObj("treeDemo");  //ztree的Id  zTreeId
	  var checkedNodes = zTreeOjb.getCheckedNodes();
	  var info = JSON.stringify(checkedNodes);
	  var json = JSON.parse(info);
	  var menuIds = '';
	  $.each(json, function(iz, obj) {
		  menuIds += ','+obj.id;
	  });
	  var entityId = $("#entityId").val();
	  var rolename = $("#rolename").val();
	  var data = {'entityId':entityId,'menuIds':menuIds,'rolename':rolename};
	  //提交成功后禁用按钮
	  $("#tjsub").css("pointer-events","none"); 
	  $.post('<%=basePath%>controller/sysRole/save',data,function(data){
		  if(data == '1'){
			  $("#tjsub").css("pointer-events","auto");
			  layer.msg('提交失败', {time:1000});
		  }
		  if(data == '0'){
			  layer.msg('提交成功', {time:1000});
			  setTimeout("layer.closeAll()",1000);
			  //window.setTimeout(refreshCount, 1000 * 5);
			  //调用刷新页面
			  setTimeout("parent.location.reload()",2000);
		  }
	  })
    return false;
  });
});
//返回按钮事件
function closeWindow(){
        var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
} 
</script>
<SCRIPT type="text/javascript">
		var setting = {
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				onMouseDown: zTreeOnMouseDown
			}
		};

		var zNodes =${MenuList};

		function zTreeOnMouseDown(event, treeId, treeNode) {
			var carmodelid = $("#carmodelid").val();
		    //打开页面
		   $("#showIframe").attr("src", '<%=basePath%>controller/carModel/showIframePage/'+carmodelid+'/'+treeNode.id);
		};
		
		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		});
	</SCRIPT>
</body>
</html>
